home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
business
/
sb10a.zip
/
_SETUP.1
/
Function.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-04-19
|
14KB
|
445 lines
/*======================================================================*/
/* function.c: sharebiz user functions */
/*======================================================================*/
/* COPYRIGHT 1995-1996 Jean-Pierre MENICUCCI - All rights reserved */
/*======================================================================*/
#include <windows.h> // windows defines
#include <time.h>
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*//////////////////////////////////////////////////////////////////////*/
/* YourAppKey : computing your user's Key */
/*//////////////////////////////////////////////////////////////////////*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
void YourAppKey (
unsigned char *in, // to code
unsigned char *out // coded
)
{
lstrcpy (out, in);
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*//////////////////////////////////////////////////////////////////////*/
/* InvoiceNumber : compute an Invoice number */
/*//////////////////////////////////////////////////////////////////////*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
void InvoiceNumber (
LPSTR sOldInvoiceNumber, // old invoice number
int cNewInvoiceNumber, // new invoice number length
LPSTR sNewInvoiceNumber // new invoice number
)
{
/************************************************/
/* invoice number of the form yy.mm.xxx where */
/* yy : 2 digit year number */
/* mm : 2 digit month number */
/* xxx : ordinal number */
/************************************************/
struct tm *newtime; // structured time
time_t long_time; // long time ...
char szBuf[18]; // temporary
int yy, mm, xxx; // time
LPSTR lp; // string
time (&long_time); // get time as long integer
newtime = localtime (&long_time); // convert to local time
lp = sOldInvoiceNumber;
yy = atoi (lp); // current year
lp = strchr (lp, '.');
mm = atoi (++lp); // current month
lp = strchr (lp, '.');
xxx = atoi (++lp); // current ordinal number
if (yy == newtime->tm_year && mm == newtime->tm_mon+1)
wsprintf (szBuf, "%02d.%02d.%02d", newtime->tm_year, newtime->tm_mon+1, xxx+1);
else
wsprintf (szBuf, "%02d.%02d.01", newtime->tm_year, newtime->tm_mon+1);
lstrcpyn (sNewInvoiceNumber, szBuf, cNewInvoiceNumber);
}
/*======================================================================*/
/* Pull: extracting a delimited substring */
/* return: */
/* extracted length */
/*======================================================================*/
/* Pull extracts the characters contained between the initial position */
/* of the pointer and the delimiter. The excess characters are not */
/* taken into account */
/*======================================================================*/
int Pull (
char **lpIn, // input string
char *lpOut, // output string
int mOut, // output size
char cDel // delimiter
)
{
int nLen = 0; // extracted length
/********************************************************************/
/* go ahead into the input string while the current character is */
/* neither an end-of-string nor a delimiter */
/********************************************************************/
for (;**lpIn && **lpIn != cDel; (*lpIn)++)
if (nLen < mOut) // if applicable
lpOut[nLen++] = **lpIn; // extract the character
/**********************************************************/
/* skip the delimiter if reached else point end-of-string */
/**********************************************************/
if (**lpIn)
(*lpIn)++;
lpOut[nLen] = '\0'; // add an end-of-string
return (nLen); // extracted length
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*//////////////////////////////////////////////////////////////////////*/
/* CompuServeMsg : process a CompuServe registration notification */
/*//////////////////////////////////////////////////////////////////////*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
BOOL CompuServeMsg (
LPSTR sBody, // input message body
int cPerson,
LPSTR sPerson, // person
int cTitle,
LPSTR sTitle, // title
int cCompany,
LPSTR sCompany, // company
int cAddress,
LPSTR sAddress, // address
int cFaxOrEMail,
LPSTR sFaxOrEMail, // fax or email
int cProductId,
LPSTR sProductId, // product id
int cLanguage,
LPSTR sLanguage, // language
int cLicensee,
LPSTR sLicensee, // license
int cReference,
LPSTR sReference, // reference
int cLicenses,
LPSTR sLicenses, // number of licenses
int cCurrency,
LPSTR sCurrency, // currency
int cPaymentMeans,
LPSTR sPaymentMeans, // payment means
int cNetAmount,
LPSTR sNetAmount, // net amount
int cTax,
LPSTR sTax, // tax
int cDeliveryCompany,
LPSTR sDeliveryCompany, // delivery company
int cDeliveryTitle,
LPSTR sDeliveryTitle, // delivery title
int cDeliveryPerson,
LPSTR sDeliveryPerson, // delivery person
int cDeliveryAddress,
LPSTR sDeliveryAddress, // delivery address
int cDeliveryFaxOrEMail,
LPSTR sDeliveryFaxOrEMail // delivery fax or email
)
{
char szLine[8192];
LPSTR pData = &szLine[23]; // data position in line
LPSTR ptr = sBody;
/*******************/
/* initialize data */
/*******************/
ZeroMemory (sPerson, cPerson);
ZeroMemory (sTitle, cTitle);
ZeroMemory (sCompany, cCompany);
ZeroMemory (sAddress, cAddress);
ZeroMemory (sFaxOrEMail, cFaxOrEMail);
ZeroMemory (sProductId, cProductId);
ZeroMemory (sLanguage, cLanguage);
ZeroMemory (sLicensee, cLicensee);
ZeroMemory (sReference, cReference);
ZeroMemory (sLicenses, cLicenses);
ZeroMemory (sCurrency, cCurrency);
ZeroMemory (sPaymentMeans, cPaymentMeans);
ZeroMemory (sNetAmount, cNetAmount);
ZeroMemory (sTax, cTax);
ZeroMemory (sDeliveryCompany, cDeliveryCompany);
ZeroMemory (sDeliveryTitle, cDeliveryTitle);
ZeroMemory (sDeliveryPerson, cDeliveryPerson);
ZeroMemory (sDeliveryAddress, cDeliveryAddress);
ZeroMemory (sDeliveryFaxOrEMail, cDeliveryFaxOrEMail);
/************/
/* get data */
/************/
Pull (&ptr, szLine, sizeof (szLine), '\r');
if (lstrcmp ("The following shareware has been registered by:", szLine))
return FALSE;
ptr++;
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
lstrcpyn (sPerson, pData, cPerson); // person
lstrcpyn (sLicensee, pData, cPerson); // licensee
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
*(pData + lstrlen (pData) - 1) = '\0';
lstrcpyn (sFaxOrEMail, pData+1, cFaxOrEMail); // fax or email
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
lstrcpyn (sCompany, pData, cCompany); // company
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
lstrcpy (sAddress, pData); // address line 1
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
if (*pData) {
lstrcat (sAddress, "\r\n");
lstrcat (sAddress, pData); // address line 2
}
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
if (*pData) {
lstrcat (sAddress, "\r\n"); // address line 3
lstrcat (sAddress, pData);
}
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
if (*pData) {
lstrcat (sAddress, "\r\n"); // address line 4
lstrcat (sAddress, pData);
}
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
lstrcpy (sProductId, pData); // product Id
Pull (&ptr, szLine, sizeof (szLine), '\r');
ptr++;
Pull (&ptr, szLine, siz